<html>
 <head>
  <title>Test Page for Components</title>
  <script language="javascript" src="../../jsunit/app/jsUnitCore.js"></script>
  <script language="javascript" src="../compiled/ca-all.js"></script>
 </head>
 <body>
  <script language="javascript">
  	var _counter = 0;
	var TComponentPartail = function(){}		
	TComponentPartail.prototype.InitializeComponent = function(component_manager){			
	};
	TComponentPartail.prototype.SetComponentID = function(cmpid){
		this.cid = cmpid;
	};
	var TComponent = function(){
	};
	TComponent.prototype = new TComponentPartail();
	TComponent.prototype.GetComponentID = function(){
		return this.cid;
	};
  	function setUp(){
		var uids = [];
		for(var i=0;i<5;i++){
			uids.push("UID_"+_counter);
			_counter++;
		}	
		CA.UID.DefaultProvider.AddUIDS(uids);	
	}
    function testCreation() {
		var oPartial = new TComponentPartail();
	    var success = false;
		try{
			CA.Components.Register(oPartial);
		}catch(e){
			success = true;
		}
		assertTrue("Should fail due to not implementing component interface",success);
		var o = new TComponent();
		success = true;
		try{
			CA.Components.Register(o);
		}catch(e){
			success = false;
		}
		assertTrue("Should succed due to implementing component interface",success);
    }
	function testGetComponentByID(){
		var o = new TComponent();
		var success = true;
		try{
			CA.Components.Register(o);
		}catch(e){
			success = false;
		}
		assertTrue("Should succed due to implementing component interface",success);
		assertEquals("Should equal its own id",o,CA.Components.Get(o.GetComponentID()));
	}
	function testUnregisterComponent(){
		var o = new TComponent();
		var success = true;
		try{
			CA.Components.Register(o);
		}catch(e){
			success = false;
		}
		assertTrue("Should succed due to implementing component interface",success);
		assertEquals("Should equal its own id",o,CA.Components.Get(o.GetComponentID()));
		CA.Components.Unregister(o);
		assertNull(CA.Components.Get(o.GetComponentID()));
	}
  </script>
 </body>
</html>